class Solution:
    def solveEquation(self, equation: str) -> str:
        equas = equation.split('=')
        left = equas[0]
        right = equas[1]

        def common(str1):
            lens = len(str1)
            x = y = 0
            key = 1
            i = 0
            while i < lens:
                if str1[i] == ' ':
                    i += 1
                    continue
                if str1[i] == '+':
                    key = 1
                elif str1[i] == '-':
                    key = -1
                else:
                    r = l = i
                    while r < lens and str1[r].isnumeric():
                        r += 1
                    if r < lens and str1[r] == 'x':
                        if r == l:
                            x += key
                        else:
                            x += int(str1[l:r]) * key
                        i = r + 1
                        continue
                    y += int(str1[l:r]) * key
                    i = r - 1
                i += 1
            return x, y

        x1, y1 = common(left)
        x2, y2 = common(right)

        x_factor = x1 - x2
        y_factor = y2 - y1
        if x_factor == 0:
            if y_factor == 0:
                return 'Infinite solutions'
            else:
                return 'No solution'
        return 'x={}'.format(y_factor // x_factor)


a = Solution()
a.solveEquation("3x =33 + 22 + 11")
